<!--
*  功能描述：项目前期信息
 -->
 <template>
  <div>
    <el-row>
      <el-col :span="24">
        <el-descriptions title="查询文档" border>
        </el-descriptions>
        <el-form :inline="true" class="demo-form-inline">
          <el-form-item label="文档名称">
            <el-input v-model="acsoryIdNmae" placeholder="联系人姓名"></el-input>
          </el-form-item>
          <el-form-item label="录入时间">
            <el-input type="date" v-model="acsoryIdTime" placeholder="联系人姓名"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
            <el-button type="info" @click="loadExcel">导出</el-button>
          </el-form-item>
        </el-form>

      </el-col>
      <el-col :span="24">
        <!-- 显示文档信息 -->
        <div class="fj">
          <el-descriptions class="margin-top" title="文档信息">
          </el-descriptions>
          <template>
            <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
              @selection-change="handleSelectionChange">
              <el-table-column type="selection" width="55">
              </el-table-column>
              <el-table-column prop="AcsoryIdNmae" label="文件名"> </el-table-column>
              <el-table-column prop="AcsoryIdTime" label="上传时间"> </el-table-column>
              <el-table-column prop="AcsoryIdSize" label="文件大小"> </el-table-column>
              <el-table-column prop="AcsoryIdType" label="文件类型"> </el-table-column>
              <el-table-column prop="AcsoryIdUser" label="用户"> </el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button size="mini" @click="editAccessorys(scope.row)">查看</el-button>
                </template>
              </el-table-column>
            </el-table>
          </template>
        </div>
      </el-col>
      <el-col :span="24">
        <a href="#" @click="pdel">删除</a>
        <div class="block">
          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="PageIndex"
            :page-sizes="[5, 10, 15, 50]" :page-size="PageSize" layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount">
          </el-pagination>
        </div>
      </el-col>
    </el-row>
    <!-- 查看附件 -->
    <el-dialog title="查看附件" :visible.sync="dialogVisibless2">
      <el-form :model="upAccessory">
        <el-form-item label="文件名：" :label-width="formLabelWidth">
          {{upAccessory.AcsoryIdNmae}}
        </el-form-item>
        <el-form-item label="上传时间：" :label-width="formLabelWidth">
          {{upAccessory.AcsoryIdTime}}
        </el-form-item>
        <el-form-item label="文件大小：" :label-width="formLabelWidth">
          {{upAccessory.AcsoryIdSize}}
        </el-form-item>
        <el-form-item label="文件类型：" :label-width="formLabelWidth">
          {{upAccessory.AcsoryIdType}}
        </el-form-item>
        <el-form-item label="用户：" :label-width="formLabelWidth">
          {{upAccessory.AcsoryIdUser}}
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibless2 = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [],
      PageIndex: 1,
      PageSize: 5,
      acsoryIdNmae: '',
      acsoryIdTime: null,
      totalCount: 50,
      dialogVisibless2: false,
      //查看附件
      upAccessory: {
        AcsoryId: '',
        AcsoryIdNmae: '',
        AcsoryIdTime: '',
        AcsoryIdSize: '',
        AcsoryIdType: '',
        AcsoryIdUser: '',
        CustomerId: '',
        multipleSelection: [],
      },
    }
  },
  methods: {
    showCustList () {//显示
      this.$http({
        url: 'Custinformation/GetAccessory',
        method: 'get',
        params: {
          acsoryIdNmae: this.acsoryIdNmae,
          acsoryIdTime: this.acsoryIdTime,
          PageIndex: this.PageIndex,
          PageSize: this.PageSize,
        }
      })
        .then(res => {
          this.tableData = res.data.list
          this.totalCount = res.data.totalCount
        })
    },
    handleSizeChange (val) {
      this.PageSize = val;
      this.showCustList();
    },
    handleCurrentChange (val) {
      this.PageIndex = val;
      this.showCustList();
    },

    onSubmit () {//查询
      this.showCustList();
    },
    editAccessorys (row) {//查看附件
      this.dialogVisibless2 = true
      this.$http({
        url: 'CustInfo/GetAccessoryFT',
        method: 'get',
        params: {
          id: row.AcsoryId
        }
      })
        .then(res => {
          this.upAccessory = res.data

        })
    },
    pdel () {//批量删除
      var ids = [];
      for (var i = 0; i < this.multipleSelection.length; i++) {
        ids.push(this.multipleSelection[i].AcsoryId)
      }
      if (ids.toString() == "") {
        alert('至少选择一条数据')
        return;
      }

      if (confirm('确定删除吗?')) {
        this.$http({
          url: 'Custinformation/DeleteAccessory',
          method: 'delete',
          params: {
            ids: ids.toString()
          }
        })
          .then(res => {
            if (res.data > 0) {
              this.$message.success('删除成功');
              this.showCustList();
              return;
            }
          })
      }
    },
    handleSelectionChange (val) {
      this.multipleSelection = val;
    },
    //导出excel
    loadExcel () {
      if (confirm("是否确定下载")) {
        window.open("Custinformation/DownloadExcel")
      }
    },
  },
  mounted () {
    this.showCustList();
    this.showTypes();
    this.showIndustry();
  }

}
</script>

<style>
</style>